<template>
  <div class="div-search-action">
    <el-select
      class='first-el-select'
      :value="deviceChoose"
      :placeholder="deviceChoosePlaceholder"
      @input="updateDeviceChoose">
      <el-option v-for="option in deviceList"
                 :key="option.value"
                 :label="option.label"
                 :value="option.value">
      </el-option>
    </el-select>
    <el-select v-show=false value="userChoose" :placeholder="$getTextByLangKey('请选择用户')" @input="updateUserChoose">
      <el-option v-for="option in userList" :key="option.value" :label="option.label" :value="option.value"></el-option>
    </el-select>
    <el-select :value="standChoose" :placeholder="$getTextByLangKey('请选择站位')" @input="updateStandChoose">
      <el-option v-for="option in standList" :key="option.value" :label="option.label"
                 :value="option.value"></el-option>
    </el-select>
    <el-date-picker :value="beginDate" @input="updateBeginDate" type="datetime"
                    :placeholder="$getTextByLangKey('请选择起始时间')"></el-date-picker>
    <el-date-picker :value="overDate" @input="updateOverDate" type="datetime"
                    :placeholder="$getTextByLangKey('请选择结束时间')"></el-date-picker>
    <el-button class='export-button' type="primary" @click="creatDialog" :disabled="!isAdmin">{{$getTextByLangKey('导出')}}</el-button>
    <el-button v-show="showDeleteFilterButton" type="danger" @click="deleteFilterRecord">{{$getTextByLangKey('删除')}}
    </el-button>
    <el-button v-show=false type="primary" @click="searchData">{{$getTextByLangKey('查找')}}</el-button>

    <br/>

    <!--<el-button class='el-button-delete-data' type="danger" v-show="isShowDeleteButton"-->
    <!--&gt;删除勾选的数据-->
    <!--</el-button>-->

    <!--<el-button class='el-button-delete-data' type="primary"-->
    <!--v-show="isShowCancelLightButton">取消高亮-->
    <!--</el-button>-->
    <el-button class='el-button-delete-data' :loading="isDeleteBtnLoading" type="danger" v-show="isShowDeleteButton"
               @click="deleteSelectionData">{{$getTextByLangKey('删除勾选的数据')}}
    </el-button>

    <el-button class='el-button-delete-data' :loading="isCancelLightBtnLoading" type="primary"
               v-show="isShowCancelLightButton"
               @click="cancelLightSelectionData">{{$getTextByLangKey('取消高亮')}}
    </el-button>

    <el-dialog :show-close=false
               :close-on-press-escape=false
               :close-on-click-modal=false
               :title="title"
               :visible.sync="dialogVisible">
      <el-row>
        <el-col :span="12">

          <el-form class="el-form-left" label-position="left" label-width="82px" :model="excelForm">
            <el-form-item :label="$getTextByLangKey('产线名称')+'：'">
              <el-input v-model="excelForm.lineName" :disabled="true"></el-input>
            </el-form-item>
            <el-form-item :label="$getTextByLangKey('程序名称')+'：'">
              <el-input v-model="excelForm.programName" :disabled="true"></el-input>
            </el-form-item>
            <el-form-item :label="$getTextByLangKey('订单编号')+'：'">
              <el-input v-model="excelForm.orderNum"></el-input>
            </el-form-item>

          </el-form>
        </el-col>
        <el-col :span="12">
          <el-form class="el-form-right" label-position="left" label-width="82px" :model="excelForm">

            <el-form-item :label="$getTextByLangKey('订单数量')+'：'">
              <el-input v-model="excelForm.orderCount"></el-input>
            </el-form-item>
            <el-form-item :label="$getTextByLangKey('客户名称')+'：'">
              <el-input v-model="excelForm.customName"></el-input>
            </el-form-item>
            <el-form-item :label="$getTextByLangKey('产品名称')+'：'">
              <el-input v-model="excelForm.productName"></el-input>
            </el-form-item>
          </el-form>
        </el-col>
      </el-row>

      <span slot="footer" class="dialog-footer">
        <el-button @click="cancelDialog">{{$getTextByLangKey('取消')}}</el-button>
        <el-button type="primary" @click="confrimDialog">{{$getTextByLangKey('确定')}}</el-button>
      </span>
    </el-dialog>

    <div class="line"></div>
  </div>
</template>
<script>

  // import Request from '@/common/js/Request'

  export default {
    name: "search-action-componet",
    props: ['chanxian', 'program', 'deviceChoose', 'deviceList', 'userChoose', 'userList', 'standChoose', 'standList', 'beginDate', 'overDate',
      'isShowDeleteButton', 'isDeleteBtnLoading', 'isShowCancelLightButton', 'isCancelLightBtnLoading', 'showDeleteFilterButton'],
    data() {
      return {
        title: this.$getTextByLangKey('请完善Excel文件的信息'),
        deviceChoosePlaceholder: this.$getTextByLangKey("请选择设备"),
        dialogVisible: false,
        excelForm: {
          lineName: '',
          programName: '',
          orderNum: '',
          orderCount: '',
          customName: '',
          productName: '',
        },

        isAdmin: localStorage.getItem("username") === 'admin'
      }
    },
    created: function () {
      this.excelForm.lineName = this.chanxian
      this.excelForm.programName = this.program
    },
    methods: {

      deleteSelectionData() {
        this.$emit('deleteSelectionData')
      },

      cancelLightSelectionData() {
        this.$emit('cancelLightSelectionData')
      },

      updateDeviceChoose: function (val) {
        this.$emit('updateValue', 'updateDeviceChoose', val)
      },
      updateUserChoose: function (val) {
        this.$emit('updateValue', 'updateUserChoose', val)
      },
      updateStandChoose: function (val) {
        this.$emit('updateValue', 'updateStandChoose', val)
      },
      updateBeginDate: function (val) {
        this.$emit('updateValue', 'updateBeginDate', val)
      },
      updateOverDate: function (val) {
        this.$emit('updateValue', 'updateOverDate', val)
      },
      searchData: function () {
        this.$emit("searchData")
      },
      creatDialog: function () {
        this.dialogVisible = true;

      },
      cancelDialog: function () {
        this.dialogVisible = false;
      },
      confrimDialog: function () {
//        if (this.excelForm.orderNum === '' || this.excelForm.orderCount === '' || this.excelForm.customName === '' || this.excelForm.productName === '') {
//          this.$message.error("请完善表单信息");
//          return
//        }
        this.dialogVisible = false;
        this.$emit('confrimDialog', this.excelForm)
      },

      deleteFilterRecord() {
        this.$emit('deleteFilterRecord')
      }
    }
  }

</script>

<style scoped>

  .div-search-action {
    line-height: 50px;

  }

  .first-el-select {
    padding-left: 10px;
  }

  .el-button-delete-data {
    margin-left: 10px;
  }

  .el-dialog__body {
    padding-top: 10px;
    padding-bottom: 0px;
  }

  .el-dialog__footer {
    padding-top: 0px;
  }

  .el-form-left {
    margin-right: 10px;
  }

  .el-form-right {
    margin-left: 10px;
  }

  .export-button {
    margin-left: 8px;
  }
</style>
